package edu.tgc.web.form.system.validation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotBlank;

@Retention(RetentionPolicy.RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Documented
@Constraint(validatedBy = {})
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 31, message = "账号长度必须在{min}到{max}个字符之间")
@Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9]*$", message = "账号必须以字母开头,只能以字母数字组成")
public @interface ValidateUsername {

    Class<?>[] groups() default {};

    String message() default "";

    Class<? extends Payload>[] payload() default {};
}
